

<div style="float: right; margin-top: 20px;">
	<?php 
	if($history == null )
		$is_submitted = false;
	else{
		// 		$last_week= new DateTime(date('Y-m-d',strtotime('monday this week')));
		// 		$last_week->sub(new DateInterval('P7D'));
		// 		$curr = new DateTime($history[0]->transaction_created_date);
		// 		if ($curr > $last_week)
		// 			$is_submitted = true;
		// 		else
		// 			$is_submitted = false;
		$last_month = date('n') - 1;
		$res_month = date('n', strtotime($history[0]->transaction_created_date));
		if ($res_month > $last_month)
			$is_submitted = true;
		else
			$is_submitted = false;

	}
	?>
	<div
		class="<?php if ($is_submitted) echo 'informationStyleGreen'; else echo 'informationStyleRed';?>">Status</div>
	<div class="informationPanel">
		<table>
			<tr>
				<td>Lastest transaction :</td>
				<td style="font-weight: 900;"><?php 
				if ($is_submitted)
					echo 'submitted';
				else
					echo 'not submitted';
				?>
				</td>
			</tr>
			<tr>
				<td>Performance <br />(compare with previous) :
				</td>
				<td style="font-weight: 900;"><?php 
				if($history == null || sizeof($history)< 2){
					echo 'unknown';
				}else{
					if ($history[0]->transaction_profit>$history[1]->transaction_profit)
						echo 'improved';
					else if ($history[0]->transaction_profit<$history[1]->transaction_profit)
						echo 'decline';
					else
						echo 'same';
				}
				?>
				</td>
			</tr>

		</table>
	</div>
</div>
<?php echo form_open('branch/updatebranch'); ?>
<br />

<div class="titleStyle1">Update Branch</div>
<div class="errorMessage">
	<?php echo validation_errors(); ?>
</div>
<div class="branch_update">
	<input name="branch_id" type="hidden"
		value="<?php echo $result->branch_id;?>" />
	<table>

		<tr>
			<td>Branch ID:</td>
			<td><?php echo $result->branch_id;?>
			</td>
		</tr>
		<tr>
			<td>Branch's Name:</td>
			<td><input class="textboxStyle6" type="text" name="name"
				placeholder="Please enter the branch"
				value="<?php echo $result->branch_name;?>" />
			</td>
		</tr>

		<tr>
			<td>Location:</td>
			<td><input class="textboxStyle6" type="text" name="location"
				placeholder="Please enter the location"
				value="<?php echo $result->branch_location;?>" />
			</td>
		</tr>

		<tr>
			<td>Tel:</td>
			<td><input class="textboxStyle6" type="text" name="tel"
				placeholder="Please enter the phone number"
				value="<?php echo $result->branch_tel;?>" />
			</td>
		</tr>

		<tr>
			<td>Active:</td>
			<td><input type="checkbox" name="active"
			<?php if ($result->branch_active) {echo 'checked';}?> />
			</td>
		</tr>
	</table>
</div>
<br />
<div>
	<input type="submit" class="buttonStyle1" value="update">
</div>
<?php echo form_close(); ?>

<br />
<br />
<hr />
<br />
<div class="titleStyle1">Transaction History</div>
<?php 

if ($history == null || sizeof($history)==0){
	echo '<div class="information">';
	echo 'no transaction history found.';
	echo '</div>';
}else {

	echo '<div class="waitingTable">';
	echo '<table>';
	echo '<tr>';
	echo '<td>';
	echo 'Submit ID';
	echo '</td>';
	echo '<td>';
	echo 'Submitted Date';
	echo '</td>';
	echo '<td>';
	echo 'Total Profit';
	echo '</td>';
	echo '<td>';
	echo 'Transaction\'s Detail';
	echo '</td>';
	echo '<td>';
	echo 'Download';
	echo '</td>';
	echo '</tr>';
	foreach ($history as $trans){
		echo '<tr>';
		echo '<td>';
		echo $trans->transaction_id;
		echo '</td>';
		echo '<td>';
		echo $trans->transaction_created_date;
		echo '</td>';
		echo '<td>';
		echo $trans->transaction_profit;
		echo '</td>';
		echo '<td style="text-align:center;">';
		if( $trans->transaction_created_date ==null){
			echo 'not submitted';
		}else
			echo '<a href="'.base_url().'index.php/transaction/view/'.$trans->transaction_id.'">view</a>';
		echo '</td>';
		echo '<td style="text-align:center;">';
		echo '<a class="downloadButton"  href="'.base_url().'uploads/transactions/'.$trans->transaction_file_location.'">download</a>';
		echo '</td>';
		echo '</tr>';
	}
	echo '</table>';
	echo '</div>';
}
?>